import { ConfigProvider } from 'antd';
import { QueryClient, QueryClientProvider } from '@tanstack/react-query';
import { RouterProvider } from 'react-router-dom';
import { router } from './router';
import { appTheme } from './styles/theme';
import { useEffect } from 'react';
import { checkAuthStatus } from './utils/auth';

const queryClient = new QueryClient();

// 初始化认证状态
const AuthInitializer = () => {
    useEffect(() => {
        const initAuth = async () => {
            await checkAuthStatus();
        };
        initAuth();
    }, []);

    return null;
};

function App() {
    return (
        <QueryClientProvider client={queryClient}>
            <ConfigProvider theme={appTheme}>
                <AuthInitializer />
                <RouterProvider router={router} />
            </ConfigProvider>
        </QueryClientProvider>
    );
}

export default App;
